home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
smixw130.zip
/
SMIXW130.DOC
< prev
next >
Wrap
Text File
|
1997-06-06
|
10KB
|
194 lines
_____ __ __ ____ __ __ _ _
/ _ \ | \ / | | | | \ / | | | | |
| / \__| | \/ | | | \ ~ / | | | |
| \___ | | | | | | | | | |
\___ \ | /\/\ | | | | | | | _ | |
__ \ | | | | | | | | | | |/ \| |
| \_/ | | | | | | | / ^ \ | _ |
\_____/ |__| |__| |____| |__/ \__| \__/ \__/
for Watcom C DOS/4GW protected mode
Version 1.30
Written by Ethan Brodsky (97/6/6)
Copyright 1995 by Ethan Brodsky. All rights reserved.
This library is distributed AS IS. The author specifically disclaims
responsibility for any loss of profit or any consequential, incidental,
or other damages. SMIX is freeware and is distributed with full source
code, which is copyright by Ethan Brodsky. You are free to incorporate
the code in full or part into your own programs as long as credit is
given to Ethan Brodsky. The source code may be distributed in its
original form only, including this documentation and the copyright
notices.
------------------------------------------------------------------------
You may have used my SBVOX and SBDSP units. They both played one VOC
file at a time. The whole VOC file had to be loaded into conventional
memory, taking valuable memory from a real mode program.
SMIX will play up to 8 sounds at one time. The sounds are stored
anywhere in memory and mixed into a small buffer as needed. It should
work with any Sound Blaster compatible sound card. It uses auto
initialized DMA if it is supported, eliminating clicks between blocks.
If a SB16 is installed, it will use 16-bit sound output, increasing the
sound quality. Full source for Watcom C protected mode using the
DOS/4GW extender is included.
The sounds are stored on disk as raw signed 8-bit sample data at a
sampling rate of 22050 HZ or the sampling rate specified in the SMIX
source file and are loaded anywhere in memory. The data is mixed into
a 16-bit buffer one block at a time, then copied down to an 8 or 16 bit
buffer in conventional memory for DMA output.
In case you are wondering about the three counters displayed by the test
program, the first one counts in the CPU's free time, the second counts
the number of interrupts that have occurred, and the third is the number
of sounds currently being played. If you have any problems, please tell
me what each counter is doing.
You can change the sampling rate used for output by changing the constant
at the top of the SMIX source file. If you decide to do this, all sound
effects must be sampled at the rate you specify, or they will play at the
wrong frequency. Higher sampling rates will increase CPU usage. Do not
use a rate larger than 22050 HZ or SMIX will not work on sound cards
older than the SB16.
SMIX either uses a raw 8-bit unsigned file format, or in a combined
resource file. I have included a program that will convert WAV files to
the raw format necessary, and a program to combine raw sound files into
a resource file. The WAV files must be 8-bit and sampled at 22050 HZ,
or the output will be distorted. If you have changed the sampling rate
constant in the SMIX source file then the sounds should be sampled at the
rate you have specified.
Use the SNDLIB utility included with this package to build sound resource
files. The syntax for SNDLIB is similar to that of Borland's TLIB, but
it is much more restrictive. Remember that resources are identified by
their "key", which comes after the filename when adding a resource. The
key is an 8 character case-insensitive string that is should be passsed
to the load sound function after you have opened the resource file.
The mixing algorithm I use for the SB16 sacrifices volume level for
precision. This means that the mixed output will be fairly quiet on
16-bit sounds cards. However, the SB16 has fairly load output, so it
should come out about right. If you think that the output is too quiet,
you can disable 16-bit output by passing "0" as the 16-bit DMA channel
to the SB initialization function, ignoring what the detect routine
returns.
One important pointer: The SMIX module MUST be compiled using the "-zu"
compiler switch. The Watcom code generator erroneously assumes that
SS == DS when generating code for an interrupt handler. The compiler
then uses EBP to address data in DS and your program will terminate
with a stack fault upon the first sound interrupt. "-zu" tells the
compiler not to make this assumption and is the best workaround for
this compiler bug. (Another option is to disable optimizations, but
then the compiler will generate terrible code) Due to the DOS/4GW
extender used for Watcom C protected mode, sound cards on IRQ10 are
not supported by this version of SMIX.
SMIX is not written in C++, but it can be used in a C++ program.
However, you must compile the SMIX, XMS, and DETECT modules as C
code, since they will not compile when treated as C++. Since the SMIX
modules are compiled as C code, function names are not mangled, and
you must tell your program not to expect mangled names. To do this,
replace your SMIX includes with this code fragment:
extern "C"
{
#include "smix.h"
#include "detect.h"
}
I have several improvements planned, but I need feedback. If you are
using my code, I would greatly appreciate it if you would mail me and
tell me about it. If you have any bug reports, suggestions, or have
made improvements, please tell me! I also have available a FM synthesis
MIDI music library and am working on a digital music library, so tell me
what you are interested in!
This library is freeware, but I would appreciate contributions so I can
continue to buy development kits and upgrade my computer. You don't
NEED to send me anything, but if you are making money by using this,
please send whatever you feel it is worth.
Features:
* Up to 8 sounds played simultaneously
* Sampling rate of 22050 HZ (changable at compile-time)
* Autoinitialized DMA prevents clicking
* 16-bit sound output increases quality
* Mixes in the background using a fraction of CPU time
* Sound volume control supported
* Sound resource files allow you to store all sounds in one file
------------------------------------------------------------------------
There are several ways to contact me:
E-Mail: ebrodsky@pobox.com (Preferred)
brodskye@cae.wisc.edu
WWW: http://www.pobox.com/~ebrodsky/
http://www.xraylith.wisc.edu/~ebrodsky/
Phone: (608) 238-4830
Mail:
Ethan Brodsky
4010 Cherokee Dr.
Madison, WI 53711
Bug fixes and other announcements will be posted in:
alt.sb.programmer
comp.archives.msdos.announce
comp.sys.ibm.pc.soundcard.tech
rec.games.programmer
Up-to-date versions may be downloaded from:
http://www.pobox.com/~ebrodsky/smix/smix.html
ftp.simtel.net /pub/simtelnet/msdos/sound/smix*.zip
x2ftp.oulu.fi /pub/msdos/programming/mxlibs/smix*.zip
Revision history:
1.11 - Initial release
1.20 - Switched to a new mixing algorithm that doesn't reduce sound
volume on 8-bit sound cards. Added support for sound volume
control. Fixed a problem with output on Sound Blaster Pros.
Optimized mixing code. Modified code in exit procedure to
reset sound card on termination.
1.21 - Modifed shutdown code
1.22 - Fixed a detection problem with sound cards on DMA0. Commented
SMIX interface. Modified interrrupt acknowledgement. Added a
sound_playing function to check if a sound is still playing.
1.23 - Fixed setup for SB16s that use an 8-bit DMA channel for 16-bit
sound. Made all internal functions static. Added sound_playing
function to smix.h and copied the interface documentation from
smix.c to smix.h.
1.24 - Added support for sound resource files. New WAV2RAW converter
that correctly converts all conformant WAV files containing the
correct type of data.
1.25 - Fixed a problem in addressing the second half of the DMA memory
area. Fixed a problem in addressing the second half of the DMA
memory area. Variable sampling rate. Added library file to
simplify linking in SMIX. Added FILE_ID.DIZ for BBS use.
1.30 - Fixed a bug in the WAV2RAW converter that caused problems with
non-typical WAV files. Removed all floating point math to avoid
linking in unnecessary floating point code and wasting time
generating volume lookup table. Fixed a minor bug in the
initialization routines that prevented SMIX from using
autoinitialized DMA on sound cards with DSP v2.00. Prevented
SMIX from installing its exit handler multiple times. Improved
mixtest example program. Changed load_sound to a function and
added error handling. Made start_sound a function, returning
whether or not it could play the sound. Switched calls to min()
and max() to my own MIN() and MAX() to avoid problems if the
macros are not implemented. Removed redundant definition of
handler_installed. Included a few extra header files to get rid
of warnings generated when full warnings are turned on. Added
instructions on how to use SMIX in a C++ program. Thanks to
Ulrich Doewich, Pawel Veselov (a.k.a. Black Angel), Bojan
Resnik, Christopher Adams, and Robert Rand for their help in
improving SMIX.
I've been looking to get in with a commercial software company. If any
companies are interested, write to me at the above address. Thanks!
Ethan Brodsky